package com.spring.demo.init.httpinvoker;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;

import com.spring.demo.core.httpinvoker.IHttpUserService;

/**
 * http invoker client config
 * 
 * @author sean
 * 
 */
@Configuration
@PropertySource({ "classpath:httpinvoker/http-client.properties" })
public class HttpClientConfig {

	private final static String HTTP_INVOKER_SERVER_URL_PROPERTY_NAME = "httpServiceUrl";

	@Autowired
	private Environment envir;

	@Bean
	public HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean() {
		HttpInvokerProxyFactoryBean bean = new HttpInvokerProxyFactoryBean();
		bean.setServiceUrl(envir
				.getProperty(HTTP_INVOKER_SERVER_URL_PROPERTY_NAME));
		bean.setServiceInterface(IHttpUserService.class);

		return bean;
	}
}
